package com.sec.android.app.myfiles.widget.listview;

import android.view.View;

import com.sec.android.app.myfiles.MyFilesTestRunner;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;

/**
 * Created by jaebae on 2016-07-28.
 */
@RunWith(MyFilesTestRunner.class)
public class testListViewHolder {
    private static final int TEST_VIEW_CNT = 16;
    private ListViewHolder mListViewHolder;
    private View mViewList[];

    @Before
    public void setUp() throws Exception {
        mViewList = new View[TEST_VIEW_CNT];
        for (int i = 0; i < TEST_VIEW_CNT; i++) {
            mViewList[i] = PowerMockito.mock(View.class);
        }
        mListViewHolder = ListViewHolder.createHolder(TEST_VIEW_CNT);
    }

    @Test
    public void testCreateHolder() {
        Assert.assertNotNull(mListViewHolder);
    }

    @Test
    public void testAddGetView() {
        for (int i = 0; i < TEST_VIEW_CNT; i++) {
            mListViewHolder.addView(i, mViewList[i]);
        }

        for (int i = 0; i < TEST_VIEW_CNT; i++) {
            View actual = mListViewHolder.getView(i);
            Assert.assertEquals(mViewList[i], actual);

            actual = mListViewHolder.getView(i, View.class);
            Assert.assertEquals(mViewList[i], actual);
        }

    }
}
